package cn.test.bookms.service.impl;

import cn.test.bookms.entity.MsBook;
import cn.test.bookms.entity.Student;
import cn.test.bookms.mapper.StudentMapper;
import cn.test.bookms.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.awt.print.Book;
import java.util.List;

/**
 * @_PackageName:cn.test.bookms.service.impl
 * @_ClassName:StudentServiceImpl
 * @_Description:
 * @_Author：笑老二
 * @_data 20/06/16 19:52
 */

@Transactional
@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper mapper;


    public List<Student> findStuByCollege(Integer c_id) {
        return mapper.findStuByCollege(c_id);
    }

    public Student findStuBySid(Integer sid) {

        return mapper.findStuBySid(sid);
    }

    public int addStuBorrowBook(Integer sid, Integer book_id) {

        return mapper.addStuBorrowBook(sid, book_id);
    }

    /**
     * 删除借书信息
     * @param sid
     * @param book_id
     * @return
     */
    public int delStuBorrow(Integer sid, Integer book_id) {
        int i = mapper.delStuBorrow(sid, book_id);
        mapper.updateBookStatus0(book_id);
        return i;
    }

    public MsBook findBookStatus(Integer book_id) {
        return mapper.findBookStatus(book_id);
    }

    public int updateBookStatus(Integer book_id) {
        return mapper.updateBookStatus(book_id);
    }

    public MsBook findLibraryBook(Integer book_id) {
        return mapper.findLibraryBookByBooKId(book_id);
    }
}
